package com.ssau.tnp.clients;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class ClientGereration {

    public static void main(String[] arg0) {

	try {
	    BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
	    System.out.println("Input dimension: ");
	    int dimension = Integer.valueOf(keyboard.readLine());
	    System.out.println("Input name of file1: ");
	    String fileName1 = keyboard.readLine();
	    System.out.println("Input name of file2: ");
	    String fileName2 = keyboard.readLine();
	    PrintWriter out1 = new PrintWriter(fileName1);
	    PrintWriter out2 = new PrintWriter(fileName2);
	    out1.println(dimension);
	    out1.println(dimension);
	    out2.println(dimension);
	    out2.println(dimension);
	    for (int i = 0; i < dimension; i++) {
		for (int j = 0; j < dimension; j++) {
		    out1.print(Math.random() * 6);
		    out1.print(" ");
		    out2.print(Math.random() * 6);
		    out2.print(" ");
		}
		out1.println("");
		out2.println("");
	    }
	    out1.flush();
	    out1.close();
	    out2.flush();
	    out2.close();

	    StupidClient client = new StupidClient(fileName1, fileName2);
	    Thread clientThread = new Thread(client);
	    clientThread.start();

	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
}
